package com.yztctech.a24_02_normalbroadcast_dynamicregist;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

/**
 * Created by bodhixu on 2016/9/23.
 * 自定义广播接收器
 * 备注:
 * 1.  这里使用了一个观察者模式将BroadcastReceiver的数据返回给观察者listener
 */
public class DownloadReceiver extends BroadcastReceiver{

    private IDownloadListener downloadListener;

    public DownloadReceiver(IDownloadListener downloadListener) {
        this.downloadListener = downloadListener;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        //获得数据------>因为有intent
        String result = intent.getStringExtra(MyConstants.KEY_RESULT);
        downloadListener.success(result);
    }

}
